package com.sphd.emanu.fragment.topupdetail;

import android.content.Context;

import com.google.gson.JsonObject;
import com.sphd.emanu.mvp.BasePresenterImpl;
import com.sphd.emanu.pojo.login.Org;
import com.sphd.emanu.utils.GsonUtil;
import com.wzutils.L;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * @Author Hu
 * @Time 2017/7/4 -- 11:14.
 * @Email 87683202@qq.com
 */
public class TopupdetailPresenter extends BasePresenterImpl<TopupdetailContract.View> implements TopupdetailContract.Presenter {

    @Override
    public void selectDepositOrder(final int org, String status) {
        emanuService.selectDepositOrder(org, status).enqueue(new Callback<String>() {
            @Override
            public void onResponse(Call<String> call, Response<String> response) {
                L.e(response.toString());
                mView.recBean(GsonUtil.GsonToBean(response.body(), Org.class));
            }

            @Override
            public void onFailure(Call<String> call, Throwable t) {
                Error(t);
            }
        });
    }

    @Override
    public void enterDepositOrder(int orderId) {
        emanuService.enterDepositOrder(orderId).enqueue(new Callback<JsonObject>() {
            @Override
            public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
                mView.recRes(res(response));
            }

            @Override
            public void onFailure(Call<JsonObject> call, Throwable t) {
                Error(t);
            }
        });
    }
}
